package LeetcodeTest_thirty_two;
//287.寻找重复的数

public class repeteNum
{
    public static void main(String[] args)
    {
        int[] nums={1,2,3,4,6,4,5};
        System.out.println(Solutions.findDuplicate(nums));
    }
}
class Solutions
{
    public static int findDuplicate(int[] nums)
    {
        int[] counts=new int[nums.length];
        counts[0]=0;
        int result=nums[0];
        for(int i=0;i<nums.length;i++)
        {
            int count=counts[nums[i]];
            if(count>0)
            {
                result = nums[i];
                break;
            }
            else
                counts[nums[i]]++;
        }
        return result;
    }
}